package com.gimi.cloud.bbp.manage.controller.userInfo;

import com.gimi.cloud.bbp.common.enums.ResponseCodeEnum;
import com.gimi.cloud.bbp.common.utils.reqhead.Response;
import com.gimi.cloud.bbp.dto.userInfo.RdUserInfoDTO;
import com.gimi.cloud.bbp.entity.userInfo.RdUserInfoEntity;
import com.gimi.cloud.bbp.manage.service.userInfo.UserInfoService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户详细信息管理
 * @author chendi
 * @date 2017年12月27日
 */
@RestController
@RequestMapping(value = "userInfo")
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    /** 获取所有user详情列表 */
    @RequestMapping(value = "/list")
    public Response list(@RequestBody RdUserInfoDTO userInfoDTO, HttpServletResponse response) {
        Response resp = new Response();
        List<RdUserInfoEntity> list = userInfoService.getUsreInfoList();
        resp.setRes_data(list);
        resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
        return resp;
    }

    /** 查询角色分页列表 */
    @RequestMapping(value = "/pageList")
    public Response pageList(@RequestBody RdUserInfoDTO userInfoDTO, HttpServletResponse response) {
    	Response resp = new Response();
    	PageInfo<RdUserInfoEntity> list = userInfoService.getUserInfoPageList(userInfoDTO);
        resp.setRes_data(list);
        resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
        return resp;
    }

    /** 查询单个user信息 */
    @RequestMapping(value = "/single")
    public Response single(@RequestBody RdUserInfoDTO userInfoDTO, HttpServletResponse response) {
        Response resp = new Response();
        RdUserInfoDTO data = userInfoService.getUserInfoSingle(userInfoDTO);
        resp.setRes_data(data);
        resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
        return resp;
    }


    @RequestMapping(value = "/update")
    public Response updateUserInfo(@RequestBody RdUserInfoDTO userInfoDTO, HttpServletResponse response) {
        Response resp = new Response();
        userInfoService.updateUserInfo(userInfoDTO);
        resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
        return resp;
    }


}
